<template>
  <view class="contain">
    <view class="address">
      <view class="address_info" v-if="address.userName">
        <view class="address_detail">{{ detail }}</view>
        <view class="address_name_wrap">
          <text>{{ address.userName }}</text>
          <text>{{ address.telNumber }}</text>
        </view>
      </view>

      <button v-else @click="chooseAddress">获取收货地址</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      address: {} //地址数据
    };
  },
  onLoad() {},
  methods: {
    //   点击按钮，获取收货地址
    chooseAddress() {
      wx.chooseAddress({
        success: result => {
          console.log(result);
          this.address = result;
        },
        fail: () => {},
        complete: () => {}
      });
    }
  },
  computed: {
    detail() {
      return (
        this.address.provinceName +
        this.address.cityName +
        this.address.countyName +
        this.address.detailInfo
      );
    }
  }
};
</script>

<style lang="scss">
.contain {
  border-bottom: 1px solid #eee;
  .address {
    padding: 30rpx;
    .address_info {
      color: #000;
      .address_detail {
        font-size: 34rpx;
        font-weight: bold;
        font-family: " PingFangSC-Medium";
      }

      .address_name_wrap {
        padding-top: 20rpx;
        text {
          margin-right: 20rpx;
        }
      }
    }
  }

  button {
	  color:$uni-theme-color;
	  border: 1rpx solid currentColor;
	  background-color: #fff;
	  width: 80%;
	  font-size: 28rpx;
  }
}
</style>
